package com.viphuli.app.tool.handler;

import android.os.CountDownTimer;

import com.viphuli.app.tool.R;
import com.viphuli.app.tool.bean.page.CommonPage;
import com.viphuli.app.tool.fragment.AccountVCodeFragment;

/**
 * 获得验证码
 * 
 * @author li.li
 *
 */
public class AccountLoginVCodeResponseHandler extends MyBaseHttpResponseHandler<AccountVCodeFragment, CommonPage> {

	@Override
	public void deal() {

		//一分钟倒计时
		CountDownTimer timer = new CountDownTimer(60 * 1000, 1000) {

			@Override
			public void onTick(long millisUntilFinished) {

				if (caller.isAdded()) {
					caller.getVcodeBtn().setBackgroundResource(R.drawable.bg_btn_un_avalible);
					caller.getVcodeBtn().setText(String.valueOf(millisUntilFinished / 1000));
				}

			}

			@Override
			public void onFinish() {

				if (caller.isAdded()) {
					caller.getVcodeBtn().setBackgroundResource(R.drawable.sl_btn_green);
					caller.getVcodeBtn().setText(caller.getString(R.string.str_account_login_vcode_btn));
					caller.setCountDown(false);//结束倒计时
				}

			}
		};

		caller.setCountDown(true);//开始倒计时
		timer.start();

	}

}
